package cn.itsource.ymcc.mq;

import cn.itsource.ymcc.domain.MediaFile;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MediaProducer {
    @Autowired
    private RocketMQTemplate rocketTemplate;

    //发送消息
    public Boolean synSend(MediaFile mediaFile){
        SendResult result = rocketTemplate.syncSend("media-topic:media-tag", mediaFile);
        System.out.println(result);
        return result.getSendStatus() == SendStatus.SEND_OK;
    }
}
